package cn.yunhe.zkclient;

import java.util.List;
import org.I0Itec.zkclient.IZkChildListener;
import org.I0Itec.zkclient.ZkClient;
import org.junit.Test;

/**
 * 客户消费者
 * 
 * @author YUNHE
 *
 */
public class Client {
	@Test
	public void subscribe() throws InterruptedException{
		ZkClient zk = new ZkClient("172.16.8.118:2181");
		zk.createPersistent("/dubbo/cn.yunhe.order/consumers/192.168.10.12",true);
		zk.subscribeChildChanges("/dubbo/cn.yunhe.order/providers", new IZkChildListener() {
			@Override
			public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
	            System.out.println(parentPath);  
	            System.out.println(currentChilds.toString());
			}
		});
		Thread.sleep(Integer.MAX_VALUE);
	}
}
